var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    price: '',
    time: '',
    cardPrice: '',
    phone: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.setData({
      cardNumber: options.card,
      price: options.canBack,
      cardPrice: options.cardPrice,
      phone: options.phone,
      time: options.time
    })
  },
  callPhone(e) {
    console.log(e.currentTarget.dataset.hotline)
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.hotline //仅为示例，并非真实的电话号码
    })
  },
  makePhone() {
    wx.makePhoneCall({
      phoneNumber: this.data.phone //仅为示例，并非真实的电话号码
    })
  },
  jumpInfo() {
    var that = this
    app.executeRequest(function (header) {
      wx.request({
        url: app.BASE_URL + '/hospitalized/getIcardDetailInfo',
        header: header,
        data: {
          cardNum: that.data.cardNumber,
        },
        success: (res) => {
          var data = res.data.data
          console.log(res)
          that.setData({
            phoneNumber: res.data.data.infos.cardOwner ? res.data.data.infos.cardOwner : '',
            isUser: res.data.data.isUser,
            cardnumber: res.data.data.infos.cardNum ? res.data.data.infos.cardNum : '',
            address: res.data.data.infos.address ? res.data.data.infos.address : '',
            cardfee: res.data.data.infos.cardFee ? res.data.data.infos.cardFee : '',
            hotline: res.data.data.infos.hotline ? res.data.data.infos.hotline : '',
            balance: res.data.data.infos.balance ? res.data.data.infos.balance : '',
          })
          console.log(that.data)
          wx.reLaunch({
            url: '../CardDetails/CardDetails?isUser=' + that.data.isUser + '&card=' + that.data.cardnumber + '&address=' + that.data.address + '&cardfee=' + that.data.cardfee + '&hotline=' + that.data.hotline + '&balance=' + that.data.balance,
          })
        }
      })
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})